﻿using System.Net.Sockets;

namespace LIK.WakeOnLan.Code
{
    internal class WolClient : UdpClient
    {
        public WolClient()
            : base()
        {
            this.EnableBroadcast = true;
            this.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
        }

        //this is needed to send broadcast packet
        public void SetClientToBrodcastMode()
        {
            if (this.Active)
            {
                this.Client.SetSocketOption(SocketOptionLevel.Socket,
                    SocketOptionName.Broadcast, 0);
            }
        }
    }
}
